package com.zxkj.commonpatrol.viewmodel;

import android.app.Application;

import androidx.annotation.NonNull;

import com.czy.basecommon.utils.base.BaseRepository;
import com.czy.basecommon.utils.base.BaseViewModel;
import com.czy.basecommon.utils.base.StateData;
import com.czy.basecommon.utils.base.StateLiveData;
import com.zxkj.commonpatrol.model.response.MediaInfoResponse;
import com.zxkj.commonpatrol.repoisity.PlayerVioceRepoisity;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class PlayerVioceViewModel extends BaseViewModel<PlayerVioceRepoisity> {
    public StateLiveData<List<String>>VicoeData=new StateLiveData<>();

    public PlayerVioceViewModel(@NonNull Application application) {
        super(application);
    }


    public void  DownVicoe(Map<Integer, MediaInfoResponse.MediaVoice> integerMediaVoiceHashMap) {
        mRepository.DownVi(integerMediaVoiceHashMap, new BaseRepository.MyBaseDataCallBack<Map<Integer, String>>() {
            @Override
            public void onDataSuccessCallBack(Map<Integer, String> integerStringMap) {
                List<String> da=new ArrayList();
                if (integerMediaVoiceHashMap.keySet().size()==0){
                    //沒有值
                    VicoeData.postFailure(404,"");
                }else{
                    for (Map.Entry<Integer, String> entry : integerStringMap.entrySet()) {
                        da.add(entry.getValue());
                    }

                    VicoeData.postSuccess(da);
                }

            }

            @Override
            public void onDataFailCallBack(Map<Integer, String> integerStringMap, Map<Integer, String> t1) {

            }
        });
    }
}
